3.2.51 \(\int \frac {f+g x+h x^2}{a+b x+c x^2} \, dx\) [151]

Optimal. Leaf size=92 \[ \frac {h x}{c}-\frac {\left (2 c^2 f-b c g+b^2 h-2 a c h\right ) \tanh ^{-1}\left (\frac {b+2 c x}{\sqrt {b^2-4 a c}}\right )}{c^2 \sqrt {b^2-4 a c}}+\frac {(c g-b h) \log \left (a+b x+c x^2\right )}{2 c^2} \]

[Out]

h*x/c+1/2*(-b*h+c*g)*ln(c*x^2+b*x+a)/c^2-(-2*a*c*h+b^2*h-b*c*g+2*c^2*f)*arctanh((2*c*x+b)/(-4*a*c+b^2)^(1/2))/
c^2/(-4*a*c+b^2)^(1/2)

________________________________________________________________________________________

Rubi [A]
time = 0.08, antiderivative size = 92, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 5, integrand size = 23, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.217, Rules used = {1671, 648, 632, 212, 642} \begin {gather*} -\frac {\tanh ^{-1}\left (\frac {b+2 c x}{\sqrt {b^2-4 a c}}\right ) \left (-2 a c h+b^2 h-b c g+2 c^2 f\right )}{c^2 \sqrt {b^2-4 a c}}+\frac {(c g-b h) \log \left (a+b x+c x^2\right )}{2 c^2}+\frac {h x}{c} \end {gather*}

Antiderivative was successfully verified.

[In]

Int[(f + g*x + h*x^2)/(a + b*x + c*x^2),x]

[Out]

(h*x)/c - ((2*c^2*f - b*c*g + b^2*h - 2*a*c*h)*ArcTanh[(b + 2*c*x)/Sqrt[b^2 - 4*a*c]])/(c^2*Sqrt[b^2 - 4*a*c])
 + ((c*g - b*h)*Log[a + b*x + c*x^2])/(2*c^2)

Rule 212

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[-b, 2]))*ArcTanh[Rt[-b, 2]*(x/Rt[a, 2])], x]
 /; FreeQ[{a, b}, x] && NegQ[a/b] && (GtQ[a, 0] || LtQ[b, 0])

Rule 632

Int[((a_.) + (b_.)*(x_) + (c_.)*(x_)^2)^(-1), x_Symbol] :> Dist[-2, Subst[Int[1/Simp[b^2 - 4*a*c - x^2, x], x]
, x, b + 2*c*x], x] /; FreeQ[{a, b, c}, x] && NeQ[b^2 - 4*a*c, 0]

Rule 642

Int[((d_) + (e_.)*(x_))/((a_.) + (b_.)*(x_) + (c_.)*(x_)^2), x_Symbol] :> Simp[d*(Log[RemoveContent[a + b*x +
c*x^2, x]]/b), x] /; FreeQ[{a, b, c, d, e}, x] && EqQ[2*c*d - b*e, 0]

Rule 648

Int[((d_.) + (e_.)*(x_))/((a_) + (b_.)*(x_) + (c_.)*(x_)^2), x_Symbol] :> Dist[(2*c*d - b*e)/(2*c), Int[1/(a +
 b*x + c*x^2), x], x] + Dist[e/(2*c), Int[(b + 2*c*x)/(a + b*x + c*x^2), x], x] /; FreeQ[{a, b, c, d, e}, x] &
& NeQ[2*c*d - b*e, 0] && NeQ[b^2 - 4*a*c, 0] &&  !NiceSqrtQ[b^2 - 4*a*c]

Rule 1671

Int[(Pq_)*((a_) + (b_.)*(x_) + (c_.)*(x_)^2)^(p_.), x_Symbol] :> Int[ExpandIntegrand[Pq*(a + b*x + c*x^2)^p, x
], x] /; FreeQ[{a, b, c}, x] && PolyQ[Pq, x] && IGtQ[p, -2]

Rubi steps

\begin {align*} \int \frac {f+g x+h x^2}{a+b x+c x^2} \, dx &=\int \left (\frac {h}{c}+\frac {c f-a h+(c g-b h) x}{c \left (a+b x+c x^2\right )}\right ) \, dx\\ &=\frac {h x}{c}+\frac {\int \frac {c f-a h+(c g-b h) x}{a+b x+c x^2} \, dx}{c}\\ &=\frac {h x}{c}+\frac {(c g-b h) \int \frac {b+2 c x}{a+b x+c x^2} \, dx}{2 c^2}+\frac {\left (2 c^2 f-b c g+b^2 h-2 a c h\right ) \int \frac {1}{a+b x+c x^2} \, dx}{2 c^2}\\ &=\frac {h x}{c}+\frac {(c g-b h) \log \left (a+b x+c x^2\right )}{2 c^2}-\frac {\left (2 c^2 f-b c g+b^2 h-2 a c h\right ) \text {Subst}\left (\int \frac {1}{b^2-4 a c-x^2} \, dx,x,b+2 c x\right )}{c^2}\\ &=\frac {h x}{c}-\frac {\left (2 c^2 f-b c g+b^2 h-2 a c h\right ) \tanh ^{-1}\left (\frac {b+2 c x}{\sqrt {b^2-4 a c}}\right )}{c^2 \sqrt {b^2-4 a c}}+\frac {(c g-b h) \log \left (a+b x+c x^2\right )}{2 c^2}\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]
time = 0.04, size = 95, normalized size = 1.03 \begin {gather*} \frac {h x}{c}+\frac {\left (2 c^2 f-b c g+b^2 h-2 a c h\right ) \tan ^{-1}\left (\frac {b+2 c x}{\sqrt {-b^2+4 a c}}\right )}{c^2 \sqrt {-b^2+4 a c}}+\frac {(c g-b h) \log \left (a+b x+c x^2\right )}{2 c^2} \end {gather*}

Antiderivative was successfully verified.

[In]

Integrate[(f + g*x + h*x^2)/(a + b*x + c*x^2),x]

[Out]

(h*x)/c + ((2*c^2*f - b*c*g + b^2*h - 2*a*c*h)*ArcTan[(b + 2*c*x)/Sqrt[-b^2 + 4*a*c]])/(c^2*Sqrt[-b^2 + 4*a*c]
) + ((c*g - b*h)*Log[a + b*x + c*x^2])/(2*c^2)

________________________________________________________________________________________

Maple [A]
time = 0.16, size = 93, normalized size = 1.01

method result size
default \(\frac {h x}{c}+\frac {\frac {\left (-b h +c g \right ) \ln \left (c \,x^{2}+b x +a \right )}{2 c}+\frac {2 \left (-a h +c f -\frac {\left (-b h +c g \right ) b}{2 c}\right ) \arctan \left (\frac {2 c x +b}{\sqrt {4 a c -b^{2}}}\right )}{\sqrt {4 a c -b^{2}}}}{c}\) \(93\)
risch \(\text {Expression too large to display}\) \(1649\)

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((h*x^2+g*x+f)/(c*x^2+b*x+a),x,method=_RETURNVERBOSE)

[Out]

h*x/c+1/c*(1/2*(-b*h+c*g)/c*ln(c*x^2+b*x+a)+2*(-a*h+c*f-1/2*(-b*h+c*g)*b/c)/(4*a*c-b^2)^(1/2)*arctan((2*c*x+b)
/(4*a*c-b^2)^(1/2)))

________________________________________________________________________________________

Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((h*x^2+g*x+f)/(c*x^2+b*x+a),x, algorithm="maxima")

[Out]

Exception raised: ValueError >> Computation failed since Maxima requested additional constraints; using the 'a
ssume' command before evaluation *may* help (example of legal syntax is 'assume(4*a*c-b^2>0)', see `assume?` f
or more deta

________________________________________________________________________________________

Fricas [A]
time = 0.37, size = 302, normalized size = 3.28 \begin {gather*} \left [\frac {2 \, {\left (b^{2} c - 4 \, a c^{2}\right )} h x - {\left (2 \, c^{2} f - b c g + {\left (b^{2} - 2 \, a c\right )} h\right )} \sqrt {b^{2} - 4 \, a c} \log \left (\frac {2 \, c^{2} x^{2} + 2 \, b c x + b^{2} - 2 \, a c + \sqrt {b^{2} - 4 \, a c} {\left (2 \, c x + b\right )}}{c x^{2} + b x + a}\right ) + {\left ({\left (b^{2} c - 4 \, a c^{2}\right )} g - {\left (b^{3} - 4 \, a b c\right )} h\right )} \log \left (c x^{2} + b x + a\right )}{2 \, {\left (b^{2} c^{2} - 4 \, a c^{3}\right )}}, \frac {2 \, {\left (b^{2} c - 4 \, a c^{2}\right )} h x - 2 \, {\left (2 \, c^{2} f - b c g + {\left (b^{2} - 2 \, a c\right )} h\right )} \sqrt {-b^{2} + 4 \, a c} \arctan \left (-\frac {\sqrt {-b^{2} + 4 \, a c} {\left (2 \, c x + b\right )}}{b^{2} - 4 \, a c}\right ) + {\left ({\left (b^{2} c - 4 \, a c^{2}\right )} g - {\left (b^{3} - 4 \, a b c\right )} h\right )} \log \left (c x^{2} + b x + a\right )}{2 \, {\left (b^{2} c^{2} - 4 \, a c^{3}\right )}}\right ] \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((h*x^2+g*x+f)/(c*x^2+b*x+a),x, algorithm="fricas")

[Out]

[1/2*(2*(b^2*c - 4*a*c^2)*h*x - (2*c^2*f - b*c*g + (b^2 - 2*a*c)*h)*sqrt(b^2 - 4*a*c)*log((2*c^2*x^2 + 2*b*c*x
 + b^2 - 2*a*c + sqrt(b^2 - 4*a*c)*(2*c*x + b))/(c*x^2 + b*x + a)) + ((b^2*c - 4*a*c^2)*g - (b^3 - 4*a*b*c)*h)
*log(c*x^2 + b*x + a))/(b^2*c^2 - 4*a*c^3), 1/2*(2*(b^2*c - 4*a*c^2)*h*x - 2*(2*c^2*f - b*c*g + (b^2 - 2*a*c)*
h)*sqrt(-b^2 + 4*a*c)*arctan(-sqrt(-b^2 + 4*a*c)*(2*c*x + b)/(b^2 - 4*a*c)) + ((b^2*c - 4*a*c^2)*g - (b^3 - 4*
a*b*c)*h)*log(c*x^2 + b*x + a))/(b^2*c^2 - 4*a*c^3)]

________________________________________________________________________________________

Sympy [B] Leaf count of result is larger than twice the leaf count of optimal. 488 vs. \(2 (88) = 176\).
time = 1.29, size = 488, normalized size = 5.30 \begin {gather*} \left (- \frac {\sqrt {- 4 a c + b^{2}} \cdot \left (2 a c h - b^{2} h + b c g - 2 c^{2} f\right )}{2 c^{2} \cdot \left (4 a c - b^{2}\right )} - \frac {b h - c g}{2 c^{2}}\right ) \log {\left (x + \frac {- a b h - 4 a c^{2} \left (- \frac {\sqrt {- 4 a c + b^{2}} \cdot \left (2 a c h - b^{2} h + b c g - 2 c^{2} f\right )}{2 c^{2} \cdot \left (4 a c - b^{2}\right )} - \frac {b h - c g}{2 c^{2}}\right ) + 2 a c g + b^{2} c \left (- \frac {\sqrt {- 4 a c + b^{2}} \cdot \left (2 a c h - b^{2} h + b c g - 2 c^{2} f\right )}{2 c^{2} \cdot \left (4 a c - b^{2}\right )} - \frac {b h - c g}{2 c^{2}}\right ) - b c f}{2 a c h - b^{2} h + b c g - 2 c^{2} f} \right )} + \left (\frac {\sqrt {- 4 a c + b^{2}} \cdot \left (2 a c h - b^{2} h + b c g - 2 c^{2} f\right )}{2 c^{2} \cdot \left (4 a c - b^{2}\right )} - \frac {b h - c g}{2 c^{2}}\right ) \log {\left (x + \frac {- a b h - 4 a c^{2} \left (\frac {\sqrt {- 4 a c + b^{2}} \cdot \left (2 a c h - b^{2} h + b c g - 2 c^{2} f\right )}{2 c^{2} \cdot \left (4 a c - b^{2}\right )} - \frac {b h - c g}{2 c^{2}}\right ) + 2 a c g + b^{2} c \left (\frac {\sqrt {- 4 a c + b^{2}} \cdot \left (2 a c h - b^{2} h + b c g - 2 c^{2} f\right )}{2 c^{2} \cdot \left (4 a c - b^{2}\right )} - \frac {b h - c g}{2 c^{2}}\right ) - b c f}{2 a c h - b^{2} h + b c g - 2 c^{2} f} \right )} + \frac {h x}{c} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((h*x**2+g*x+f)/(c*x**2+b*x+a),x)

[Out]

(-sqrt(-4*a*c + b**2)*(2*a*c*h - b**2*h + b*c*g - 2*c**2*f)/(2*c**2*(4*a*c - b**2)) - (b*h - c*g)/(2*c**2))*lo
g(x + (-a*b*h - 4*a*c**2*(-sqrt(-4*a*c + b**2)*(2*a*c*h - b**2*h + b*c*g - 2*c**2*f)/(2*c**2*(4*a*c - b**2)) -
 (b*h - c*g)/(2*c**2)) + 2*a*c*g + b**2*c*(-sqrt(-4*a*c + b**2)*(2*a*c*h - b**2*h + b*c*g - 2*c**2*f)/(2*c**2*
(4*a*c - b**2)) - (b*h - c*g)/(2*c**2)) - b*c*f)/(2*a*c*h - b**2*h + b*c*g - 2*c**2*f)) + (sqrt(-4*a*c + b**2)
*(2*a*c*h - b**2*h + b*c*g - 2*c**2*f)/(2*c**2*(4*a*c - b**2)) - (b*h - c*g)/(2*c**2))*log(x + (-a*b*h - 4*a*c
**2*(sqrt(-4*a*c + b**2)*(2*a*c*h - b**2*h + b*c*g - 2*c**2*f)/(2*c**2*(4*a*c - b**2)) - (b*h - c*g)/(2*c**2))
 + 2*a*c*g + b**2*c*(sqrt(-4*a*c + b**2)*(2*a*c*h - b**2*h + b*c*g - 2*c**2*f)/(2*c**2*(4*a*c - b**2)) - (b*h
- c*g)/(2*c**2)) - b*c*f)/(2*a*c*h - b**2*h + b*c*g - 2*c**2*f)) + h*x/c

________________________________________________________________________________________

Giac [A]
time = 3.62, size = 89, normalized size = 0.97 \begin {gather*} \frac {h x}{c} + \frac {{\left (c g - b h\right )} \log \left (c x^{2} + b x + a\right )}{2 \, c^{2}} + \frac {{\left (2 \, c^{2} f - b c g + b^{2} h - 2 \, a c h\right )} \arctan \left (\frac {2 \, c x + b}{\sqrt {-b^{2} + 4 \, a c}}\right )}{\sqrt {-b^{2} + 4 \, a c} c^{2}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((h*x^2+g*x+f)/(c*x^2+b*x+a),x, algorithm="giac")

[Out]

h*x/c + 1/2*(c*g - b*h)*log(c*x^2 + b*x + a)/c^2 + (2*c^2*f - b*c*g + b^2*h - 2*a*c*h)*arctan((2*c*x + b)/sqrt
(-b^2 + 4*a*c))/(sqrt(-b^2 + 4*a*c)*c^2)

________________________________________________________________________________________

Mupad [B]
time = 0.25, size = 132, normalized size = 1.43 \begin {gather*} \frac {h\,x}{c}+\frac {\ln \left (c\,x^2+b\,x+a\right )\,\left (h\,b^3-g\,b^2\,c-4\,a\,h\,b\,c+4\,a\,g\,c^2\right )}{2\,\left (4\,a\,c^3-b^2\,c^2\right )}+\frac {\mathrm {atan}\left (\frac {b}{\sqrt {4\,a\,c-b^2}}+\frac {2\,c\,x}{\sqrt {4\,a\,c-b^2}}\right )\,\left (h\,b^2-g\,b\,c+2\,f\,c^2-2\,a\,h\,c\right )}{c^2\,\sqrt {4\,a\,c-b^2}} \end {gather*}

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((f + g*x + h*x^2)/(a + b*x + c*x^2),x)

[Out]

(h*x)/c + (log(a + b*x + c*x^2)*(b^3*h + 4*a*c^2*g - b^2*c*g - 4*a*b*c*h))/(2*(4*a*c^3 - b^2*c^2)) + (atan(b/(
4*a*c - b^2)^(1/2) + (2*c*x)/(4*a*c - b^2)^(1/2))*(2*c^2*f + b^2*h - 2*a*c*h - b*c*g))/(c^2*(4*a*c - b^2)^(1/2
))

________________________________________________________________________________________